package com.onlineClass.edu.controller;

import com.onlineClass.edu.base.BaseApiController;
import com.onlineClass.edu.base.BaseResponse;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 该接口为测试接口
 *
 * @author 余胜军
 * @ClassName TestController
 */
@RestController
@Slf4j
public class TestController extends BaseApiController {
    /**
     * 测试代码
     *
     * @return
     */
    @GetMapping("/test")
    public String test() {
        return "test";
    }
    @GetMapping("/test1")
    public BaseResponse test1(String name,Integer age){
        if (StringUtils.isEmpty(name))return super.setResultError("name is null");
        if (ObjectUtils.isEmpty(age))return super.setResultError("age is null");
        return super.setResultSuccess();
    }
    @GetMapping("/test2")
    public BaseResponse test2(Integer age){
            int num = 1/age;
        System.out.println("try-catch后面的语句");



        return super.setResultSuccess();
    }

    @GetMapping("/test04")
    @ApiOperation(value = "测试传递参数1", notes = "测试传递参数1111")
    @ApiImplicitParam(paramType = "query", name = "name", value = "传递name", required = true)
    public BaseResponse test04(String name) {
        log.info("name:{}", name);
        return setResultSuccess();
    }
}
